package com.todo.delicacy.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.delicacy.application.frontend.service.RestaurantInfoAggService;
import com.todo.delicacy.iface.frontend.RestaurantFrontendIface;
import com.todo.delicacy.iface.frontend.request.QueryRestaurantByNameParam;
import com.todo.delicacy.iface.frontend.request.QueryRestaurantByPageParam;
import com.todo.delicacy.iface.frontend.request.QueryRestaurantDetailParam;
import com.todo.delicacy.iface.frontend.request.RecommendRestaurantByCityParam;
import com.todo.delicacy.iface.frontend.response.RestaurantBaseVO;
import com.todo.delicacy.iface.frontend.response.RestaurantDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/6/4 20:47
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/food")
@Tag(name = "餐馆前台接口", description = "餐馆前台接口")
public class RestaurantFrontendController implements RestaurantFrontendIface {

    @Resource
    private RestaurantInfoAggService restaurantInfoAggService;


    @Override
    @Operation(summary = "查询餐馆美食详情")
    @PostMapping("/queryRestaurantDetailById")
    public BizResponse<RestaurantDetailVO> queryRestaurantDetailById(QueryRestaurantDetailParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return restaurantInfoAggService.queryRestaurantDetailById(param);
    }

    @Override
    @Operation(summary = "根据城市获取推荐饭点列表")
    @PostMapping("/recommendRestaurantListByCity")
    public BizResponse<List<RestaurantBaseVO>> recommendRestaurantListByCity(RecommendRestaurantByCityParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return restaurantInfoAggService.recommendRestaurantListByCity(param);
    }

    @Override
    @Operation(summary = "分页查询饭点信息列表")
    @PostMapping("/queryRestaurantByPage")
    public BizPageResponse<RestaurantBaseVO> queryRestaurantByPage(QueryRestaurantByPageParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return restaurantInfoAggService.queryRestaurantByPage(param);
    }

    @Override
    @Operation(summary = "根据名称查询饭点信息列表")
    @PostMapping("/queryRestaurantListByName")
    public BizResponse<List<RestaurantBaseVO>> queryRestaurantListByName(QueryRestaurantByNameParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return restaurantInfoAggService.queryRestaurantListByName(param);
    }
}
